package com.example.crm.dao.impl;

import com.example.crm.dao.IUserDAO;
import com.example.tools.DBUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class UserDAOImpl implements IUserDAO
{
    @Override
    public boolean findByUseranmePassword(String username, String password) throws SQLException
    {
        // 1. 连接数据库
        Connection conn = DBUtils.getConnection();

        // 2. 得到查询对象
        Statement stmt = conn.createStatement();

        // 3. 执行sql语句
        String sql = "select * from user where username = '"+username + "' and password='" + password+"';";
        System.out.println(sql);
        ResultSet rs = stmt.executeQuery(sql);

        // 4. 得到结果集
        // 5. 返回结果
        if(rs.next())
        {
            return true;
        }
        else
        {
            return false;
        }


    }
}
